<?php

class MediatorController extends Controller_Base
{

    public function indexAction()
    {

        $pn = intval($this->getRequest()->getQuery('page', 1));
        if(ISMOBILE) {
            $limit = intval($this->getRequest()->getQuery('limit', 1000));
        }else{
            $limit = intval($this->getRequest()->getQuery('limit', 10));
        }
        $pn = $pn ? $pn : 1;
        $pageSize = $limit;
        $start = ($pn - 1) * $pageSize;
        $list = Module_User_Administrator::getInstance()->getAllBySearch(['name,workerId,showWorkerId,avatarImg'], array('where' => ['showWorkerId>0','status=1'], 'start' => $start, 'order' => 'showWorkerId', 'limit' => $limit));


        foreach ($list as &$mediator){
            $mediator['phone'] = '1234556';
        }
        $total = Module_User_Administrator::getInstance()->getAllBySearch(['count(id) as total'], ['where' => ['showWorkerId>0','status=1']]);
        $total = $total[0]['total'];
        //计算分页
        $totalPage = ceil($total / $pageSize);

        SmartyAdapter::assign('list', $list);
        SmartyAdapter::assign('limit', $limit);
        SmartyAdapter::assign('totalPage', $totalPage);
        SmartyAdapter::assign('totalnum', $total);
        SmartyAdapter::assign('pagesize', $pageSize);
        SmartyAdapter::assign('curPageNum', $pn);
        SmartyAdapter::assign('page_query',  http_build_query([]));
        SmartyAdapter::assign('query', []);
    }

}